<html>
	<link rel="stylesheet" type="text/css" href="table.css" />
	<title>Search Result</title>
	<body> 
	{if $isDisplayingHistory == "true" && isset($isDisplayingHistory)}
		<h2> DISPLAY HISTORY {$index} </h2> 
		<font size = 1>Appendix : (Wine name), (year), (grape_variety), (winery_name), (region_name)</font><br/>
	
		<br>
		{$notice}<br>
		<a href = 'searchScreen.php'>Back to Search Screen Page</a><br><br>
		<center>
			<table class='stats' cellspacing='0'>
				<tr><td colspan='4' class='helpHed'>Search Result</td></tr>
				<tr>
					<td class='helpHed'>Wine Name</td>
					<td>Year</td>
					<td>Grape Variety</td>
					<td>Winery Name</td>
					<td>Region Name</td>
					<td>Min. Cost on hand</td>
					<td>Total Stock on hand</td>
					<td>Total Stock Sold in {$state} state</td>
					<td>Total number of customers who purchased the wine in {$state} state</td>
				</tr>
		{section name=i loop=$queryResult}
			<tr>
					<td>{$queryResult[i].wine_name}</td>
					<td>{$queryResult[i].year}</td>
					<td>{$queryResult[i].variety}</td>
					<td>{$queryResult[i].winery_name}</td>
					<td>{$queryResult[i].region_name}</td>
					<td>${$queryResult[i].cost}</td>
					<td>{$queryResult[i].on_hand}</td>
					<td>{$queryResult[i].totalStockSold}</td>
					<td>{$queryResult[i].totalCust}</td>
				</tr>
		{/section}
					</table>
		</center>
		Total Record = {$result}
		
	{elseif $isDisplayingHistory == "error"}
		<h2> DISPLAY HISTORY </h2> 
		NO HOT LINKING!! SOME ERROR HAPPENED TO THE SESSION. MAYBE YOUR SESSION IS ALREADY EXPIRED!
	{else}
		<h2> QUERY RESULT </h2> 
		Search Criteria : <br>
		{$searchCriteria} 
		<table>
		<tr>
			<td><font size = 2><i>Share on FaceBook :</i></font></td> <td><font size = 2><i>Share on Twitter : </i></font></td>
		</tr>
		<tr>
			<td><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></td>
			<td><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="s3274282 :: wine Search">Tweet</a></td>
		</tr>
			
		<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><br>
		</table>
		<br>
		{$notice}<br>
		<a href = 'searchScreen.php'>Back to Search Screen Page</a><br><br>
		{if $result == 0 && isset($result)}
			No records match your search criteria
		{elseif $yearIsValid eq 'false' && isset($yearIsValid)}
			Start year must be before end year
		{elseif $minNoStockIsValid eq 'false' && isset($minNoStockIsValid)}
			Minimum number of wine in stock field HAS TO BE a number only!!
		{elseif $minNoOrderIsValid eq 'false' && isset($minNoOrderIsValid)}
			Minimum number of wine ordered field HAS TO BE a number only!!
		{else}
				<center>
			<table class='stats' cellspacing='0'>
				<tr><td colspan='4' class='helpHed'>Search Result</td></tr>
				<tr>
					<td class='helpHed'>Wine Name</td>
					<td>Year</td>
					<td>Grape Variety</td>
					<td>Winery Name</td>
					<td>Region Name</td>
					<td>Min. Cost on hand</td>
					<td>Total Stock on hand</td>
					<td>Total Stock Sold in {$state} state</td>
					<td>Total number of customers who purchased the wine in {$state} state</td>
				</tr>
			{section name=i loop=$queryResult}
				<tr>
					<td>{$queryResult[i].wine_name}</td>
					<td>{$queryResult[i].year}</td>
					<td>{$queryResult[i].variety}</td>
					<td>{$queryResult[i].winery_name}</td>
					<td>{$queryResult[i].region_name}</td>
					<td>${$queryResult[i].cost}</td>
					<td>{$queryResult[i].on_hand}</td>
					<td>{$queryResult[i].totalStockSold}</td>
					<td>{$queryResult[i].totalCust}</td>
				</tr>
			{/section}
			</table>
		</center>
		Total Record = {$result}
		{/if}
	{/if}
	
	</body>
</html>